package cn.duhengkui.national.valuelist.example.config;

import java.sql.SQLException;

import javax.sql.DataSource;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;

@Configuration
public class DataSourceConfig {

	@Primary
	@Bean("firstDataSource")
	@ConfigurationProperties("spring.datasource.druid.one")
	public DataSource dataSourceOne(){
		DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
		try {
			dataSource.setFilters("stat,wall,slf4j");
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return dataSource;
	}
	
	@Bean("secendDataSource")
	@ConfigurationProperties("spring.datasource.druid.two")
	public DataSource dataSourceTwo(){
		DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
		try {
			dataSource.setFilters("stat,wall,slf4j");
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return dataSource;
	}
}
